/**
 * 
 */
package tests;

import control.elements.Avatar;
import control.elements.helpers.Dark;
import control.elements.helpers.ElementType;
import control.elements.helpers.Fire;
import junit.framework.TestCase;

/**
 * @author Scott
 *
 */
public class AvatarTest extends TestCase {

	private Avatar test_pet;
	
	public static final int TEST_LEVEL = 90;
	
	public static final String TEST_PET = "Dark Spirit";
	
	public static final ElementType TEST_ELEMENT = new Dark();
	
	
	/**
	 * @param name
	 */
	public AvatarTest(String name) {
		super(name);
		test_pet = new Avatar(TEST_LEVEL, TEST_PET);
	}

	/* (non-Javadoc)
	 * @see junit.framework.TestCase#setUp()
	 */
	protected void setUp() throws Exception {
		super.setUp();
	}

	/* (non-Javadoc)
	 * @see junit.framework.TestCase#tearDown()
	 */
	protected void tearDown() throws Exception {
		super.tearDown();
	}

	/**
	 * Test method for {@link control.elements.Avatar#Avatar(int, java.lang.String)}.
	 */
	public final void testAvatar() {
		Avatar pet = new Avatar(90, "Dark Spirit");
		assertSame(pet.getName(), test_pet.getName());
		assertSame(pet.getElement(), test_pet.getElement());
		assertEquals(pet.calculatePerp(), test_pet.calculatePerp());
	}

	/**
	 * Test method for {@link control.elements.Avatar#getElement()}.
	 */
	public final void testGetElement() {
		ElementType e1 = new Fire();
		assertFalse(e1.isSameAs(test_pet.getElement()));
		ElementType e2 = new Dark();
		assertTrue(e2.isSameAs(test_pet.getElement()));
	}

	/**
	 * Test method for {@link control.elements.Avatar#getName()}.
	 */
	public final void testGetName() {
		final String ifrit = "Ifrit";
		final String ds = "Dark Spirit";	
		assertFalse(test_pet.getName().equals(ifrit));
		assertTrue(test_pet.getName().equals(ds));
	}

	/**
	 * Test method for {@link control.elements.Avatar#calculatePerp()}.
	 */
	public final void testCalculatePerp() {
		final int elemental_at_twenty = 6; 
		final int elemental_at_fortytwo = 11;
		final int ifrit_at_seventythree = 12;
		final int fenrir_at_five = 1;
		final int carby_at_eightyone = 10;
		
		Avatar ele1 = new Avatar(20, "Light Spirit");
		Avatar ele2 = new Avatar(42, "Dark Spirit");
		Avatar ifr = new Avatar(73, "Ifrit");
		Avatar fen = new Avatar(5, "Fenrir");
		Avatar car = new Avatar(81, "Carbuncle");
		
		assertEquals("Ele1",elemental_at_twenty,ele1.calculatePerp());
		assertEquals("Ele2",elemental_at_fortytwo,ele2.calculatePerp());
		assertEquals("Ifr",ifrit_at_seventythree,ifr.calculatePerp() );
		assertEquals("Fen",fenrir_at_five,fen.calculatePerp());
		assertEquals("Car",carby_at_eightyone,car.calculatePerp() );
		
	}

}
